home *** CD-ROM | disk | FTP | other *** search
/ Shirley Barber's Fairies: Create, Paint & Play / Fairies.iso / pc / Files / ColourIn.dxr / Internal_6_Fill Brush.ls < prev    next >
Encoding:
Text File  |  2003-09-29  |  2.4 KB  |  81 lines

  1. property spriteNum, pGrObject, pMember, ColourHex, memberNumber, mySquishSound
  2. global BrushColour
  3.  
  4. on beginSprite me
  5.   pMember = member(memberNumber)
  6.   pGrObject = member(pMember).image
  7. end
  8.  
  9. on mouseUp me
  10.   global vlGame
  11.   puppetSound(1, mySquishSound)
  12.   tx = 8
  13.   ty = 59
  14.   viC = member(pMember).image.getPixel(tx, ty)
  15.   if ColourHex = VOID then
  16.     ColourHex = rgb(255, 255, 255)
  17.   end if
  18.   if viC <> rgb(ColourHex) then
  19.     BrushColour = rgb(ColourHex)
  20.     fvFill(tx, ty, rgb(ColourHex), viC)
  21.   end if
  22. end
  23.  
  24. on fvFill x, y, colorData, colorBack
  25.   seedList = []
  26.   currentSeed = 1
  27.   newUpperSeedFound = 1
  28.   newLowerSeedFound = 1
  29.   indexPoint = [#x: 0, #y: 0]
  30.   indexPoint.x = x
  31.   indexPoint.y = y
  32.   repeat while pGrObject.getPixel(indexPoint.x, indexPoint.y) = colorBack
  33.     indexPoint.x = indexPoint.x - 1
  34.   end repeat
  35.   indexPoint.x = indexPoint.x + 1
  36.   repeat while pGrObject.getPixel(indexPoint.x, indexPoint.y) = colorBack
  37.     if pGrObject.getPixel(indexPoint.x, indexPoint.y - 1) = colorBack then
  38.       if newUpperSeedFound then
  39.         add(seedList, [#x: 0, #y: 0])
  40.         seedList[currentSeed].x = indexPoint.x
  41.         seedList[currentSeed].y = indexPoint.y - 1
  42.         currentSeed = currentSeed + 1
  43.         newUpperSeedFound = 0
  44.       end if
  45.     else
  46.       newUpperSeedFound = 1
  47.     end if
  48.     if pGrObject.getPixel(indexPoint.x, indexPoint.y + 1) = colorBack then
  49.       if newLowerSeedFound then
  50.         add(seedList, [#x: 0, #y: 0])
  51.         seedList[currentSeed].x = indexPoint.x
  52.         seedList[currentSeed].y = indexPoint.y + 1
  53.         currentSeed = currentSeed + 1
  54.         newLowerSeedFound = 0
  55.       end if
  56.     else
  57.       newLowerSeedFound = 1
  58.     end if
  59.     indexPoint.x = indexPoint.x + 1
  60.     if currentSeed > 120 then
  61.       return 0
  62.     end if
  63.   end repeat
  64.   repeat while pGrObject.getPixel(x - 1, y) = colorBack
  65.     x = x - 1
  66.   end repeat
  67.   pGrObject.draw(x, y, indexPoint.x, y, [#shapeType: #line, #lineSize: 1, #color: colorData])
  68.   i = 1
  69.   repeat while i < currentSeed
  70.     if fvFill(seedList[i].x, seedList[i].y, colorData, colorBack) = 0 then
  71.       return 0
  72.     end if
  73.     i = i + 1
  74.   end repeat
  75.   return 1
  76. end
  77.  
  78. on getPropertyDescriptionList
  79.   return [#ColourHex: [#comment: "Hexidecimal Colour ie. FE2437", #format: #string, #default: "FFFFFF"], #memberNumber: [#comment: "The Member Number to be filled", #format: #member, #default: EMPTY], #mySquishSound: [#comment: "Sound Name for Paint Dab", #format: #sound, #default: "squish"]]
  80. end
  81.